package jpa.service.common;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.apache.log4j.Logger;

public class SessionEntityManager {
	
	private static final Logger log = Logger .getLogger(SessionEntityManager.class);
	
	private EntityManagerFactory emf = null;
	private EntityManager em  = null;
	
	public EntityManager CreatedEntityManager() throws Exception {
		if(emf == null)
			emf = Persistence.createEntityManagerFactory("SYNCHRO");
		if(em == null)
			em = emf.createEntityManager();
		
		return em;
	}
	
	public EntityManagerFactory XcreateEntityManagerFactory() throws Exception {
		
		if(emf == null)
			emf = Persistence.createEntityManagerFactory("SYNCHRO");
		
		return emf;
	}
	
}
